<template>
  <div class="app-container">

    <el-card style="height: 900px;">
      <!--查询-->
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
        <el-form-item label="身份证号" prop="personId">
          <el-input
            v-model="queryParams.personId"
            placeholder="请输入身份证号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form>
      <!--显示确诊人员信息-->
      <el-card style="width: 500px;height: 800px;background-color: white;float: left" >
        <el-table v-loading="loading" :data="diagnostic_infoList" >
          <el-table-column label="序号" type="index" width="50"/>
          <el-table-column label="姓名" align="center" prop="person.name" />
          <el-table-column label="身份证号" align="center" width="200" prop="personId" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-link"
                @click="handleChain(scope.row)"
              >生成传播链</el-button>
            </template>
          </el-table-column>
        </el-table>
          <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-card>

<!--   传播链显示组件   -->
      <el-card style="width: 1100px;height: 800px;background-color: white;float: left;margin-left: 1%" >
        <graph :graphData=graphData></graph>
      </el-card>

    </el-card>
  </div>
</template>




<script>
import { listDiagnostic_info } from "@/api/eim/diagnostic_info";
import graph from "@/views/eim/diagnostic_chain/graph";
import {getDiagnostic_chain} from "@/api/eim/diagnostic_chain";

export default {
  name: "chain",
  components:{graph},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 确诊信息表格数据
      diagnostic_infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        personId: null,
        controlLimitTime: null,
        symptom: null,
        checkId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        personId: [
          { required: true, message: "身份证号不能为空", trigger: "blur" }
        ],
      },
      //传播链信息
      graphData:{}
    };
  },
  created() {
    this.getList();
  },
  methods: {

    /** 查询确诊信息列表 */
    getList() {
      this.loading = true;
      listDiagnostic_info(this.queryParams).then(response => {
        this.diagnostic_infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        personId: null,
        controlLimitTime: null,
        symptom: null,
        checkId: null,
        createTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 生成传播链 */
    handleChain(row){
      //根据确诊人personId获取传播链信息
      getDiagnostic_chain(row.personId).then(response => {
        this.graphData=response.data;
      });
    }
  }
};
</script>
<style>
</style>
